#include"historyreport.h"
sqlite3 *database_init(void)
{
    sqlite3 *db;
    if (sqlite3_open("./datahistory.db", &db) != SQLITE_OK)
    {
        fprintf(stderr, "%s", sqlite3_errmsg(db));
        return NULL;
    }
    char *errmsg;
    if (sqlite3_exec(db, "create table temperature(time long primary key,data float);", NULL,
                     NULL, &errmsg) != SQLITE_OK)
    {
        fprintf(stderr, "create table temperature err %s\n", errmsg);
    }
    printf("table temperature establish ok\n");
    if (sqlite3_exec(db, "create table humidity(time long primary key,data float);", NULL,
                     NULL, &errmsg) != SQLITE_OK)
    {
        fprintf(stderr, "create table humidity err %s\n", errmsg);
    }
    printf("table humidity establish ok\n");
    return db;
}